package com.hznc.wcs.excel.listener;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.diboot.core.util.BeanUtils;
import com.diboot.core.util.ContextHolder;
import com.diboot.core.util.V;
import com.hznc.wcs.excel.model.WarehousePositionImportModel;
import com.diboot.file.excel.listener.FixedHeadExcelListener;
import com.hznc.wcs.entity.wcs.WarehousePosition;
import com.hznc.wcs.service.wcs.WarehousePositionService;

import java.util.List;
import java.util.ArrayList;
import java.util.Map;

/**
* 库位 导入Listener定义
*
* @author MyName
* @version 1.0
* @date 2024-11-28
 * Copyright © MyCorp
*/
public class WarehousePositionImportListener extends FixedHeadExcelListener<WarehousePositionImportModel> {
    /**
    * 自定义校验规则
    *
    * @param dataModelList    待保存的数据
    * @param requestParams  请求参数
    */
    @Override
    protected void additionalValidate(List<WarehousePositionImportModel> dataModelList, Map<String, Object> requestParams) {
        // 附加校验
    }

    /**
    * 保存数据
    *
    * @param dataModelList 待保存的数据
    * @param requestParams 请求参数
    */
    @Override
    public void saveData(List<WarehousePositionImportModel> dataModelList, Map<String, Object> requestParams) {
        if (V.isEmpty(dataModelList)) {
            return;
        }
        List<WarehousePosition> entityList = BeanUtils.convertList(dataModelList, WarehousePosition.class);
        ContextHolder.getBean(WarehousePositionService.class).createEntities(entityList);
    }
}
